#include "stdio.h"

struct information
{
    int num;
    char name[10];
    int score[3];
};
struct information student[3];

int sum[3];
int ans[3];

int main()
{
    void input(struct information *x);
    input(student);
    void average(struct information *y);
    average(student);
    void sort();
    sort();
    for(int i=0;i<3;i++)
    {
        printf("%d %s %d %d %d\n",student[i].num,student[i].name,student[i].score[0],student[i].score[1],student[i].score[2]);
    }
}

void input(struct information *x)
{
    for(int i=0;i<3;i++)
    {
        scanf("%d %s %d %d %d",&((x+i)->num),(x+i)->name,&((x+i)->score[0]),&((x+i)->score[1]),&((x+i)->score[2]));
    }
}

void average(struct information *y)
{
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<3;j++)
        {
            sum[i]+=(y+i)->score[j];
        }
        ans[i]=sum[i]/3;
    }
}
void sort()
{
    struct information temp;
    for(int i=0;i<2;i++)
    {
        for(int j=0;j<2-i;j++)
        {
            if(ans[j]>ans[j+1])
            {
                temp=student[j];
                student[j]=student[j+1];
                student[j+1]=temp;
            }
        }
    }
}
